package com.ruoyi.doorcontrol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.doorcontrol.domain.ThFaceRecords;
import com.ruoyi.doorcontrol.service.IThFaceRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门禁刷脸记录Controller
 * 
 * @author zhang
 * @date 2024-07-20
 */
@RestController
@RequestMapping("/doorcontrol/faceRecords")
public class ThFaceRecordsController extends BaseController
{
    @Autowired
    private IThFaceRecordsService thFaceRecordsService;

    /**
     * 查询门禁刷脸记录列表
     */
    @PreAuthorize("@ss.hasPermi('doorcontrol:faceRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(ThFaceRecords thFaceRecords)
    {
        startPage();
        List<ThFaceRecords> list = thFaceRecordsService.selectThFaceRecordsList(thFaceRecords);
        return getDataTable(list);
    }

    /**
     * 导出门禁刷脸记录列表
     */
    @PreAuthorize("@ss.hasPermi('doorcontrol:faceRecords:export')")
    @Log(title = "门禁刷脸记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ThFaceRecords thFaceRecords)
    {
        List<ThFaceRecords> list = thFaceRecordsService.selectThFaceRecordsList(thFaceRecords);
        ExcelUtil<ThFaceRecords> util = new ExcelUtil<ThFaceRecords>(ThFaceRecords.class);
        util.exportExcel(response, list, "门禁刷脸记录数据");
    }

    /**
     * 获取门禁刷脸记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('doorcontrol:faceRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(thFaceRecordsService.selectThFaceRecordsById(id));
    }

    /**
     * 新增门禁刷脸记录
     */
    @PreAuthorize("@ss.hasPermi('doorcontrol:faceRecords:add')")
    @Log(title = "门禁刷脸记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ThFaceRecords thFaceRecords)
    {
        return toAjax(thFaceRecordsService.insertThFaceRecords(thFaceRecords));
    }

    /**
     * 修改门禁刷脸记录
     */
    @PreAuthorize("@ss.hasPermi('doorcontrol:faceRecords:edit')")
    @Log(title = "门禁刷脸记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ThFaceRecords thFaceRecords)
    {
        return toAjax(thFaceRecordsService.updateThFaceRecords(thFaceRecords));
    }

    /**
     * 删除门禁刷脸记录
     */
    @PreAuthorize("@ss.hasPermi('doorcontrol:faceRecords:remove')")
    @Log(title = "门禁刷脸记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(thFaceRecordsService.deleteThFaceRecordsByIds(ids));
    }
}
